
/***********#**************
 * Author = Joker
 * createTime = 2022/12/1 10:52
 * describe = User数据文件
 * ---------meta数据---------
 * title = 用户
 * ***********#**************/
import React, {useEffect, useState} from 'react';
import UserHtml from "./html.jsx";
import store from "../../../store/index.js";
import {Button} from "antd";
import {defaultAction} from '../../../store/actionCreator'
import {useNavigate} from "react-router-dom";
import formatTime from "../../../tools/formatTime.js";
import http from "../../../http/index.js";
function User(props) {
    const storeState = store.getState();
    const navigate = useNavigate();
    const [thisTime,setThisTime] = useState(formatTime(new Date()))
    const [qinhua,setQinhua] = useState('');
    const setDefault = ()=>{
        store.dispatch(defaultAction(Math.random()))
    }
    const jump = (path)=>{
        navigate(path)
    }
    const updateTime = ()=>{
        setThisTime(formatTime(new Date()))
    }
    const getQinhua = ()=>{
        http.get('/api/rand.qinghua',{format:'json'}).then(res=>{
            setQinhua(res.content);
        })
    }
    useEffect(()=>{
        getQinhua();
    },[])
    const childProps = {
        qinhua,
        storeState,
        setDefault,
        jump,
        thisTime,
        updateTime,
        getQinhua
    }
    return (
        <div>
            <UserHtml {...childProps}></UserHtml>
        </div>
    );
}

export default User;